package com.zzhua.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * @see WebListener 其它可实现的Listener接口
 */
@WebListener
public class AnnoListener implements ServletContextListener {

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        ServletContext servletContext = sce.getServletContext();
        servletContext.setAttribute("contextPath", servletContext.getContextPath());
        System.out.println("已经设置了CONTEXTPATH");
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        System.out.println("web容器销毁");
    }
}
